package cn.terminus.data.customer.customcontacts.impl;

import cn.terminus.common.customer.bean.customcontacts.dto.*;
import cn.terminus.data.customer.customcontacts.dao.CustomContactsDao;
import cn.terminus.data.customer.customcontacts.mapper.CustomContactsMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomContacts)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:18:41
 */
@Repository
public class CustomContactsDaoImpl implements CustomContactsDao {
    @Resource
    private CustomContactsMapper customContactsMapper;

    @Override
    public Integer add(CustomContactsNewDto dto) {
        return customContactsMapper.add(dto);
    }

    @Override
    public Integer update(CustomContactsEditDto dto) {
        return customContactsMapper.update(dto);
    }

    @Override
    public List<CustomContactsResultDto> gets(CustomContactsGetsDto dto) {
        return customContactsMapper.gets(dto);
    }

    @Override
    public List<CustomContactsResultDto> query(CustomContactsQueryDto dto) {
        return customContactsMapper.query(dto);
    }

    @Override
    public Integer delete(CustomContactsDeleteDto dto) {
        return customContactsMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomContactsResultDto> page(CustomContactsQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomContactsResultDto> result = (Page<CustomContactsResultDto>) customContactsMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomContactsResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer addMulti(List<CustomContactsNewDto> list) {
        return customContactsMapper.addMulti(list);
    }

    @Override
    public List<CustomContactsResultDto> queryByCustomIds(List<Long> customerIdList) {
        return customContactsMapper.queryByCustomIds(customerIdList);

    }
}
